// 品牌管理接口
// 统一管理用户相关接口
import http from '@/utils/request'

import type { categoryListType, formValueType, attrListType, attrItemType } from './type.ts'

// 通过枚举统一管理接口
enum API {
  GETCATEGORY1_URL = '/admin/product/getCategory1',
  GETCATEGORY2_URL = '/admin/product/getCategory2',
  GETCATEGORY3_URL = '/admin/product/getCategory3',
  REMOVETRADEMARK_URL = '/admin/product/inner/findBaseCategory3ByCategory3IdList',
  ATTRINFOLIST_URL = '/admin/product/attrInfoList',
  DELETEATTRINFO_URL = '/admin/product/deleteAttr',
  SAVEATTRINFO_URL = '/admin/product/saveAttrInfo',
}

// 获取一级分类
export const getCategory1API = () => http.get<any, categoryListType>(API.GETCATEGORY1_URL)

// 获取二级分类，需要携带一级分类id
export const getCategory2API = (id: number) => http.get<any, categoryListType>(API.GETCATEGORY2_URL + `/${id}`)

// 获取三级分类，需要携带二级分类id
export const getCategory3API = (id: number) => http.get<any, categoryListType>(API.GETCATEGORY3_URL + `/${id}`)

// 获取商品基础属性
export const getAttrInfoAPI = ({ category1Id, category2Id, category3Id }: formValueType) => http.get<any, attrListType>(API.ATTRINFOLIST_URL + `/${category1Id}/${category2Id}/${category3Id}`)

// 删除商品基础属性
export const deleteAttrInfoAPI = (id: number) => http.delete<any, any>(API.DELETEATTRINFO_URL + `/${id}`)

// 添加属性与修改属性
export const saveAttrInfoAPI = (data: attrItemType) => http.post<any, any>(API.SAVEATTRINFO_URL, data)